//
//  JobCerticationViewCell.m
//  MyProject
//
//  Created by 石小强 on 2018/5/7.
//  Copyright © 2018年 yanjiaming. All rights reserved.
//

#import "JobCerticationViewCell.h"

@implementation JobCerticationViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    // [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"PingFang SC" size:50] range:NSMakeRange(0, 1)];
    
    self.centerView.layer.borderWidth = 1;
    self.centerView.layer.borderColor = [UIColorFromRGB(0x6CBECB) CGColor];
    
    self.reselectBtn.layer.cornerRadius = 8;
    self.reselectBtn.layer.masksToBounds = YES;
}

- (void)updateImageViewDatasWithIndex:(NSInteger)index andImage:(UIImage *)image {
    if (index == self.pageIndex) {
        self.certerViewImageB.hidden = YES;
        self.centerViewImageView.hidden = NO;
        self.centerViewImageView.image = image;
        self.reselectBtn.hidden = NO;
        self.centerViewDeleteBtn.hidden = NO;
    }
}

- (void)setPageIndex:(NSInteger)pageIndex {
    _pageIndex = pageIndex;
    
    self.pageControl.currentPage = pageIndex;
    
    if (pageIndex == 0) {
        self.centerViewTitleL.text = @"工牌";
        
        NSString *msgOne = @"提交本人工牌，确保公司、职位、";
        NSString *msgTwo = @"姓名处清晰与个人资料一致";
        
        NSMutableAttributedString *one = [[NSMutableAttributedString alloc] initWithString:msgOne];
        NSMutableAttributedString *two = [[NSMutableAttributedString alloc] initWithString:msgTwo];
        
        [one addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xAAABAB) range:NSMakeRange(0, 4)];
        [two addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xAAABAB) range:NSMakeRange(2, 10)];
        
        self.centerViewBottomOneL.attributedText = one;
        self.centerViewBottomTwoL.attributedText = two;
        self.centerViewBottomThreeL.hidden = YES;
        
        if (_work_card_key && _work_card_image) {
            self.certerViewImageB.hidden = YES;
            self.centerViewImageView.hidden = NO;
            self.centerViewImageView.image = _work_card_image;
            self.reselectBtn.hidden = NO;
            self.centerViewDeleteBtn.hidden = NO;
        } else {
            self.certerViewImageB.hidden = NO;
            self.centerViewImageView.hidden = YES;
            self.centerViewImageView.image = nil;
            self.centerViewDeleteBtn.hidden = YES;
            self.reselectBtn.hidden = YES;
        }
    } else if (pageIndex == 1) {
        self.centerViewTitleL.text = @"企业邮箱";
        
        NSString *msgOne = @"提交公司邮箱截图，确保公司、职";
        NSString *msgTwo = @"位、姓名、邮箱地址处信息清晰且";
        NSString *msgThree = @"与个人资料一致。";
        
        NSMutableAttributedString *one = [[NSMutableAttributedString alloc] initWithString:msgOne];
        NSMutableAttributedString *two = [[NSMutableAttributedString alloc] initWithString:msgTwo];
        
        [one addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xAAABAB) range:NSMakeRange(0, 9)];
        [two addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xAAABAB) range:NSMakeRange(9, 6)];
        
        self.centerViewBottomOneL.attributedText = one;
        self.centerViewBottomTwoL.attributedText = two;
        self.centerViewBottomThreeL.hidden = NO;
        self.centerViewBottomThreeL.text = msgThree;
        
        if (_company_email_key && _company_email_image) {
            self.certerViewImageB.hidden = YES;
            self.centerViewImageView.hidden = NO;
            self.centerViewImageView.image = _company_email_image;
            self.reselectBtn.hidden = NO;
            self.centerViewDeleteBtn.hidden = NO;
        } else {
            self.certerViewImageB.hidden = NO;
            self.centerViewImageView.hidden = YES;
            self.centerViewImageView.image = nil;
            self.centerViewDeleteBtn.hidden = YES;
            self.reselectBtn.hidden = YES;
        }
        
    } else if (pageIndex == 2) {
        self.centerViewTitleL.text = @"劳动合同";
        
        NSString *msgOne = @"提交本人公司邮箱截图，确保公司、职";
        NSString *msgTwo = @"位、姓名、邮箱地址处信息清晰且";
        NSString *msgThree = @"与个人资料一致。";
        
        NSMutableAttributedString *one = [[NSMutableAttributedString alloc] initWithString:msgOne];
        NSMutableAttributedString *two = [[NSMutableAttributedString alloc] initWithString:msgTwo];
        
        [one addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xAAABAB) range:NSMakeRange(0, 9)];
        [two addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xAAABAB) range:NSMakeRange(9, 6)];
        
        self.centerViewBottomOneL.attributedText = one;
        self.centerViewBottomTwoL.attributedText = two;
        self.centerViewBottomThreeL.hidden = NO;
        self.centerViewBottomThreeL.text = msgThree;
        
        if (_labor_contract_key && _labor_contract_image) {
            self.certerViewImageB.hidden = YES;
            self.centerViewImageView.hidden = NO;
            self.centerViewImageView.image = _labor_contract_image;
            self.reselectBtn.hidden = NO;
            self.centerViewDeleteBtn.hidden = NO;
        } else {
            self.certerViewImageB.hidden = NO;
            self.centerViewImageView.hidden = YES;
            self.centerViewImageView.image = nil;
            self.centerViewDeleteBtn.hidden = YES;
            self.reselectBtn.hidden = YES;
        }
    } else if (pageIndex == 3) {
        self.centerViewTitleL.text = @"在职证明";
        
        NSString *msgOne = @"提交当前公司的在职证明，确保公";
        NSString *msgTwo = @"司、职位、姓名处清晰，并加";
        NSString *msgThree = @"盖公章。";
        
        NSMutableAttributedString *one = [[NSMutableAttributedString alloc] initWithString:msgOne];
        NSMutableAttributedString *two = [[NSMutableAttributedString alloc] initWithString:msgTwo];
        
        [one addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xAAABAB) range:NSMakeRange(0, 14)];
        [two addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xAAABAB) range:NSMakeRange(7, 6)];
        
        self.centerViewBottomOneL.attributedText = one;
        self.centerViewBottomTwoL.attributedText = two;
        self.centerViewBottomThreeL.hidden = NO;
        self.centerViewBottomThreeL.text = msgThree;
        
        if (_incumbency_certification_key && _incumbency_certification_image) {
            self.certerViewImageB.hidden = YES;
            self.centerViewImageView.hidden = NO;
            self.centerViewImageView.image = _incumbency_certification_image;
            self.reselectBtn.hidden = NO;
            self.centerViewDeleteBtn.hidden = NO;
        } else {
            self.certerViewImageB.hidden = NO;
            self.centerViewImageView.hidden = YES;
            self.centerViewImageView.image = nil;
            self.centerViewDeleteBtn.hidden = YES;
            self.reselectBtn.hidden = YES;
        }
    }
    self.selectedIndicatorL.text = self.centerViewTitleL.text;
}


- (IBAction)certerViewImageBtnClick:(id)sender {
    self.imageBtnBlock(self.pageIndex, self);
}

- (IBAction)reselectBtnClick:(id)sender {
    self.reselectBtnBlock(self.pageIndex, self);
}

- (IBAction)deleteBtnClick:(id)sender {
    self.deleteBtnBlock(self.pageIndex, self);
}

@end
